#ifndef MANAGER_H_
#define MANAGER_H_

#include <iostream>
#include <list>
#include <string>
#include <ext/hash_map>
#include <queue>
#include "URL.h"
#include "TimedURL.h"
#include "Dominio.h"

class TimeComparison
{
public:
  bool operator() (const TimedURL& lhs, const TimedURL&rhs) const
  {
    return ( int( lhs.getTimestamp() ) > int( rhs.getTimestamp() ) );
  }
};

class Manager {
public:
	Manager() { 
	}
	void setList(std::list <URL>);
	void populateDictionaryMap();
	void printDictionaryMapInfo();
	void populateWaitList();
	void populateReadyList();
	void printWaitList();
	URL getNextReadyURL() {
		if (!readyList.empty()) {
			URL url = readyList.front();
			readyList.pop_front();
			return url;
		}
		URL url("", "", "");
		return url;
	}
	void updateDomain(std::string dominio);
	
private:
	std::string getRobots(std::string);
	
	std::list <URL> urlList;
	__gnu_cxx::hash_map<uint, Dominio> map;
	std::list<std::string> dictionary;
	std::priority_queue<TimedURL, std::vector<TimedURL>, TimeComparison > waitList;
	std::list<URL> readyList;
	static const uint maxWaitListSize;
	static const uint maxReadyListSize;
};


#endif /*MANAGER_H_*/
